package com.yunxi.order.config;

import feign.Logger;
import feign.Retryer;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;


/**
 * 订单服务配置
 *
 * @author: lidy
 * @date: 2025-01-17 14:25
 */
@Configuration
public class OrderConfig {

    /**
     * RestTemplate 配置
     *
     * @return RestTemplate
     */
    @LoadBalanced   // 注解式负载均衡
    @Bean
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    /**
     * OpenFeign 开启日志
     *
     * @return 日志配置
     */
    @Bean
    Logger.Level feignLoggerLevel() {
        return Logger.Level.FULL;
    }

    /**
     * OpenFeign 重试配置
     *
     * @return 重试器
     */
//    @Bean
    Retryer retryer() {
        return new Retryer.Default();
    }

}
